<?php

class ContactInformation
{
    var $OfficePhone;
    var $CellPhone;
    var $HomePhone;
    var $Fax;
    var $Pager;
    var $Email;
    var $URL;
	
	function PrintElement()
	{
	    echo $this->OfficePhone;
	    echo $this->CellPhone;
	    echo $this->HomePhone;
	    echo $this->Fax;
	    echo $this->Pager;
	    echo $this->Email;
	    echo $this->URL;
		echo "<br/>";
	}
	function AddItemFromXML( $xmlFormat )
	{
		$Array = $xmlFormat->children();		
	     $this->OfficePhone = $Array[0];
	     $this->CellPhone = $Array[1];
	     $this->HomePhone = $Array[2];
	     $this->Fax = $Array[3];
	     $this->Pager = $Array[4];
	     $this->Email = $Array[5];
	     $this->URL = $Array[6];
	}
}

class Agent
{
	var $FirstName;
	var $LastName;
	var $ContactInfo;
	var $MyAddress;
	var $ListingServuceName;
	var $AgentID;
	var $OfficeID;
	var $ModifyTime;
	
	function PrintElement()
	{
		echo $this->FirstName . "<br/>";
		echo $this->LastName . "<br/>";
		//$this->ContactInfo->PrintElement();
		echo $this->MyAddress . "<br/>";
		echo $this->ListingServuceName . "<br/>";
		echo $this->AgentID . "<br/>";
		echo $this->OfficeID . "<br/>";
		echo $this->ModifyTime . "<br/>";
    }
}
//echo "Test";

$xml = simplexml_load_file("ListOfAgent.xml");

//echo $xml->getName()."<br/>";

foreach($xml->children()->children()->children() as $child1)
{
	echo $child1->getName() . ": " . $child1 . "<br/>";
	$OneAgent = new Agent;
	XmlPrint($child1, &$OneAgent);
	$OneAgent->PrintElement();
	break;
}

function XmlPrint( $XmlArray, $Agents)
{
	//echo $XmlArray->getName() . ": " . $XmlArray . "<br/>";
	$Array = $XmlArray->children();
	//$Agents = new Agent;
	
	//var $FirstName;echo $Array[0];
	$Agents->FirstName = $Array[0];
	
	//var $LastName;echo $Array[1];
	$Agents->LastName = $Array[1];//$XmlArray->children();
	
	//var $ContactInfo;echo $Array[2];
	//$Agents->ContactInfo = $Array[2];//$XmlArray->children();
	$Agents->ContactInfo = new ContactInformation;
	$Agents->ContactInfo->AddItemFromXML($Array[2]);
	
	//var $Address;echo $Array[3];
	//->getName();//$XmlArray->children();
	$Addr = $Array[3]->children();
	$Agents->MyAddress = $Addr[0];
	
	//var $ListingServuceName;echo $Array[4];
	$Agents->ListingServuceName = $Array[4];//$XmlArray->children();
	
	//var $AgentID;echo $Array[5];
	$Agents->AgentID = $Array[5];//$XmlArray->children();
	
	//var $OfficeID;echo $Array[6];
	$Agents->OfficeID = $Array[6];//$XmlArray->children();
	
	//var $ModifyTime;echo $Array[7];
	$Agents->ModifyTime = $Array[7];//$XmlArray->children();
	
	//$Agents->PrintElement();

	
}

?>